﻿using SupermarketManager.Core;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SupermarketManager.DataAccess
{
    class DangnhapAccess
    {
        public DangnhapAccess()
        {
        }
        dbConnection dbConn = new dbConnection();
        //---- Lấy tài khoản
        public DataTable layTaikhoan(String user, String pass)
        {
            DataTable dt = new DataTable();
            SqlParameter[] p = new SqlParameter[2];
            SqlParameter tk = new SqlParameter("@Taikhoan", SqlDbType.NVarChar, 30);
            tk.Value = user;
            p[0] = tk;
            p[1] = new SqlParameter("@Matkhau", pass);
            dt = dbConn.executeSelectProcedureQuery("select_nguoidung", p);
            return dt;
        }

        //---- Kiểm tra đăng nhập hợp lệ không
        public bool kiemtraDangnhap(String user, String pass)
        {
            DataTable dt = new DataTable();
            dt = layTaikhoan(user, pass);
            if ((dt.Rows.Count) > 0) return true;
            else return false;
        }
    }
}
